import patato as pat
import matplotlib.pyplot as plt
# Load the photoacoustic data
pa_data = pat.PAData.from_hdf5("../patato_data/invivo_oe.hdf5")

# Obtain time series data:
ts = pa_data.get_time_series()
raw_data = ts.raw_data

# Make an image of the time series data
plt.imshow(raw_data[0, 0], aspect="auto")
plt.title("Photoacoustic time series data")
plt.ylabel("Detector index")
plt.xlabel("Time sample")
plt.colorbar(label="PA Signal (a.u.)")
plt.show()

# The saved reconstructed images can be obtained as follows:
reconstruction = pa_data.get_scan_reconstructions()["Reference Backprojection", "0"]

# Show an image of the reconstruction
reconstruction.imshow()

# Overlay the regions of interest:
for (name, _), roi in pa_data.get_rois().items():
    plt.plot(*roi.points.T, label =" ".join(name.split("_")[::-1]))
plt.legend(frameon=False, labelcolor="white")

plt.title("Mouse cross-sectional image")
plt.show()